package run;

import com.SpringApplications;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.reactive.config.EnableWebFlux;
import utils.Utils;


@SpringBootTest(classes = {SecurityDemo.Dummy.class},
        webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class SecurityDemo {
    Object lock = new Object();
    @Autowired
    DefaultListableBeanFactory beanFactory;

    /**
     * todo mockMvc test
     */
//    @Autowired
//    MockMvc mockMvc;
//     MockMvc mockMvc = webAppContextSetup(wac).build();
//    @Test
//    public void verify2() throws Exception {
//        mockMvc.perform(MockMvcRequestBuilders.get("/")
//                .with(SecurityMockMvcRequestPostProcessors.csrf()))
//                .andReturn();
//    }

    @Test
    public void verify() throws InterruptedException {

        Utils.print(beanFactory);

        ClassPathResource classPathResource= new ClassPathResource("templates/test.html");
        boolean exists = classPathResource.exists();
        Assertions.assertTrue(exists);

        synchronized (lock){
            lock.wait();;
        }
    }

    @Import(SpringApplications.class)
    @Configuration
    @EnableAutoConfiguration
    public  static class Dummy{

    }
}
